package com.violet.uaa.server.auth.service.impl;

import com.violet.common.entity.Permission;
import com.violet.common.util.ObjectCopyUtil;
import com.violet.uaa.server.auth.dto.PermissionDTO;
import com.violet.uaa.server.auth.mapper.PermissionMapper;
import com.violet.uaa.server.auth.service.PermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: wqf
 * @Date: 2024/08/31
 * @Description:
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Resource
    private PermissionMapper permissionMapper;

    /**
     * 方法描述: 查询用户的接口权限信息
     *
     * @param userId 用户id
     * @return java.util.List<com.violet.uaa.server.auth.entity.Permission>
     * @author wqf
     * @date 2024/8/31 10:28
     */
    @Override
    public List<PermissionDTO> findByUserId(Long userId) {
        List<Permission> permissionList = permissionMapper.findByUserId(userId);
        return ObjectCopyUtil.copyListProperties(permissionList, PermissionDTO::new);
    }
}
